package cn.teaey.apns.network;
/**
 * User: Teaey
 * Date: 13-8-29
 */
public abstract class BaseAppleServer implements AppleServer
{
    private       String       proxyHost;
    private       int          proxyPort;
    private final AppleGateway appleGateway;
    private final boolean      isProduction;
    public BaseAppleServer(AppleGateway appleGateway, boolean isProduction)
    {
        checkNull(appleGateway);
        this.appleGateway = appleGateway;
        this.isProduction = isProduction;
    }
    private void checkNull(Object object)
    {
        if (null == object)
        {
            throw new NullPointerException();
        }
    }
    public String getHost()
    {
        return isProduction ? appleGateway.getProductionHost() : appleGateway.getDevelopmentHost();
    }
    public int getPort()
    {
        return isProduction ? appleGateway.getProductionPort() : appleGateway.getDevelopmentPort();
    }
    @Override
    public String getProxyHost()
    {
        return proxyHost;
    }
    @Override
    public int getProxyPort()
    {
        return proxyPort;
    }
    @Override
    public void setProxy(String proxyHost, int proxyPort)
    {
        this.proxyHost = proxyHost;
        this.proxyPort = proxyPort;
    }
}
